package com.cndw.kungfu.model.skill;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.cndw.kungfu.dao.SkillDao;
import com.cndw.kungfu.dao.SkillModeDao;
import com.cndw.kungfu.domain.BuffMode;
import com.cndw.kungfu.domain.Skill;
import com.cndw.kungfu.domain.SkillMode;

/**
 * 技能管理
 * @author fantadust
 * @date 2011-5-5 下午09:23:02
 */
@Component
public class SkillManger {
	
	@Autowired
	private SkillModeDao modeDao;
	@Autowired
	private SkillDao dao;
	
	

	

	
	public void insert(Skill skill){
		try {
			dao.insert(skill);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	
	public void changePosition(int position,long playerId,int skillLibId){
		try {
			dao.update(position, playerId, skillLibId);
		} catch (Exception e) {
			e.printStackTrace();
		}		
	}
	
	
	public Map<Integer, Skill> getSkillByPlayerIdFromDb(long playerId){		
		return dao.getByPlayerId(playerId);
	}
	/**
	 * 获取全部技能
	 * @return
	 */
	public List<SkillMode> getAllSkillFromDb(){
		try {
			return modeDao.selectSkillModes();
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
		
	}	
	
	/**
	 * 获取系统buff集合
	 * @return
	 */
	public Map<Integer, BuffMode> loadSysBuffFromDb(){
		try {
			Map<Integer, BuffMode> map = modeDao.selectBuff();			
			return map;
			
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
		
	}	
	
}
